<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="js/vuejs-2.5.16.js"></script>

</head>
<body>

        <div id="app">

               <input type="text" @keydown="fun($event)">



        </div>
</body>


<script>
        new Vue({
            el:"#app",
            methods:{
                fun:function(event){
                    if(event.keyCode<48 || event.keyCode>57){   //说明按下的不是数字  0对应的Ascii 48  1对应的Ascii 49  9对应57
                        event.preventDefault();     //阻止默认行为
                    }
                }


            }

        })
</script>

</html>